import { Byte } from '../../api/io/Byte';
import { HashMap } from '../../api/struct/HashMap';


export const enum E_CDLotteryList {
	/**id*/
	id,
	/**活动id*/
	activityID,
	/**功能解锁id*/
	fuctionUnlock,
	/**名称*/
	name,
	/**描述*/
	desc,
	/**横幅背景*/
	banner,
	/**显示召唤类型--1.装备--2.宠物*/
	showType,
	/**是否可以左右切换,1-可以，其他-不行*/
	scroll,

	/**枚举数量*/
	EnumCount
}



export class CDLotteryList{
	/**id*/
	public id: number;
	/**活动id*/
	public activityID: number;
	/**功能解锁id*/
	public fuctionUnlock: number;
	/**名称*/
	public name: number;
	/**描述*/
	public desc: number;
	/**横幅背景*/
	public banner: number;
	/**显示召唤类型--1.装备--2.宠物*/
	public showType: number;
	/**是否可以左右切换,1-可以，其他-不行*/
	public scroll: number;


	/**获取属性值*/
	public getAttr(idx: number): any {
		switch(idx) { 
			default: return;
			case E_CDLotteryList.id: return this.id;
			case E_CDLotteryList.activityID: return this.activityID;
			case E_CDLotteryList.fuctionUnlock: return this.fuctionUnlock;
			case E_CDLotteryList.name: return this.name;
			case E_CDLotteryList.desc: return this.desc;
			case E_CDLotteryList.banner: return this.banner;
			case E_CDLotteryList.showType: return this.showType;
			case E_CDLotteryList.scroll: return this.scroll;
		}
	}



	/**设置属性值*/
	public setAttr(idx: number, v: any): void {
		switch(idx) { 
			default: break;
			case E_CDLotteryList.id: this.id = v; break;
			case E_CDLotteryList.activityID: this.activityID = v; break;
			case E_CDLotteryList.fuctionUnlock: this.fuctionUnlock = v; break;
			case E_CDLotteryList.name: this.name = v; break;
			case E_CDLotteryList.desc: this.desc = v; break;
			case E_CDLotteryList.banner: this.banner = v; break;
			case E_CDLotteryList.showType: this.showType = v; break;
			case E_CDLotteryList.scroll: this.scroll = v; break;
		}
	}


	/**数据*/
	public static datas: HashMap<number, CDLotteryList> = new HashMap<number, CDLotteryList>();



	/**加载数据*/
	public static load(byte: Byte): void{
		const size = byte.readInt32();
		const list : CDLotteryList[] = [];
		let i :number;

		for (i = 0; i < size; i++) {
			list[i] = new CDLotteryList();
		}
		for (i = 0; i < size; i++) {
			list[i].id = byte.readInt32();
			this.datas.put(list[i].id, list[i]);
		}
		for (i = 0; i < size; i++) {
			list[i].activityID = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].fuctionUnlock = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].name = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].desc = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].banner = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].showType = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].scroll = byte.readInt8();
		}
	}


	/** 获取数据*/
	public static getData(id: number): CDLotteryList{
		return this.datas ? this.datas.get(id) : null;
	}
}
